import pandas as pd
from pitchSrc.tools.fusionDecorator import FusionDecorator
from common.config import pitchConfig as Config

from pitchSrc.tools.getPlotly import show3dFig



@FusionDecorator.fusion
def onlFusionProcess(X):
    print('online fusionProcess 进行中................')
    return X

def fusionToCsv(from1, from1Attr, from2, from2Attr, to3, to3Attr, funtionName):
    X1 = pd.read_csv(from1)
    attr1 = pd.read_csv(from1Attr)
    X2 = pd.read_csv(from2)
    attr2 = pd.read_csv(from2Attr)
    pointsCount1 = attr1.loc[0,'历史数据长度']
    pointsCount2 = attr2.loc[0,'历史数据长度']

    X3 = funtionName(X1, pointsCount1, X2, pointsCount2)

    X3.to_csv(to3, index=False)
    attr3 = pd.DataFrame({'len': len(X3), 'path': to3, '历史数据长度': [pointsCount1 * Config.attenuationRatio + pointsCount2]})
    attr3.to_csv(to3Attr, index=False)
    print('toCsv 完毕................')


if __name__ == '__main__':
    fusionToCsv(Config.onlSurfaceProcess, Config.onlSurfaceAttr
                , Config.onlSmoothProcess, Config.onlSmoothAttr
                , Config.onlFusionProcess, Config.onlFusionAttr
                , onlFusionProcess)
    print('onlilne fusionProcess 完毕................')
    show3dFig(Config.onlFusionProcess)
